/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ReclamacionView.java
 *
 * Created on 09/12/2009, 10:08:42 PM
 */

package vista;

import controlador.IReclamacionController;
import modelo.IReclamacion;
import modelo.IReclamacionModel;
/**
 *
 * @author LEONIC
 */
public class ReclamacionView extends javax.swing.JFrame implements IReclamacionView{

    private IReclamacionModel model;
    private IReclamacionController controller;

    private ReclamacionTableModel tableModel;
    private JPanelReclamacion panelReclamacion;
    /** Creates new form ReclamacionView */
    public ReclamacionView() {
        tableModel=new ReclamacionTableModel();
        initComponents();

        this.panelReclamacion=new JPanelReclamacion(this);
        this.panelabajo.add(this.panelReclamacion);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panelabajo = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTableReclamacion1 = new javax.swing.JTable();

        setTitle("Crear Reclamacion");

        panelabajo.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        panelabajo.setLayout(new javax.swing.BoxLayout(panelabajo, javax.swing.BoxLayout.LINE_AXIS));

        jTableReclamacion1.setModel(tableModel);
        jTableReclamacion1.setUpdateSelectionOnSort(false);
        jScrollPane2.setViewportView(jTableReclamacion1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(28, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(panelabajo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 443, Short.MAX_VALUE))
                .addGap(25, 25, 25))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(panelabajo, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(27, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ReclamacionView().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTableReclamacion1;
    private javax.swing.JPanel panelabajo;
    // End of variables declaration//GEN-END:variables

    public IReclamacionController getController() {
        return controller;
    }

    public void setController(IReclamacionController controller) {
        this.controller=controller;
    }

    public IReclamacionModel getModel() {
        return model;
    }

    public void setModel(IReclamacionModel model) {
        this.model=model;
    }

    public void dataModelChanged() {
        refresh();
    }

    public void display() {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                setVisible(true);
                refresh();
            }
        });
    }

    protected void refresh() {
        this.tableModel.setReclamaciones(getModel().obtenerReclamacion());
    }

    protected void fireActualizaEmpleadoGesture(int idReclamacion, int codArticulo, String observaciones, String nombreArticulos) {
        getController().nuevoReclamacionGesture(idReclamacion,codArticulo,observaciones,nombreArticulos);
    }

    protected void fireEliminarEmpleadoGesture(int idReclamacion, int codArticulo, String observaciones, String nombreArticulos) {
        getController().EliminarReclamacionGesture(idReclamacion, codArticulo, observaciones, nombreArticulos);
    }
}
